<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>相册列表 - 社交平台</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome 图标 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    
    <style>
        :root {
            --primary: #3b82f6;
            --primary-light: #60a5fa;
            --primary-dark: #2563eb;
            --secondary: #8b5cf6;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --text-primary: #111827;
            --text-secondary: #6b7280;
            --text-light: #9ca3af;
            --bg-light: #f9fafb;
            --bg-white: #ffffff;
            --border-light: #e5e7eb;
            --border-medium: #d1d5db;
            --radius: 8px;
            --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background-color: var(--bg-light);
            color: var(--text-primary);
            padding-top: 55px;
            padding-bottom: 60px;
        }
        
        /* 顶部导航 */
        .top-nav {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 55px;
            background-color: var(--bg-white);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 15px;
            z-index: 1000;
            border-bottom: 1px solid var(--border-light);
        }
        
        .nav-title {
            font-size: 1.1rem;
            font-weight: 600;
        }
        
        .nav-actions {
            display: flex;
            gap: 15px;
            font-size: 1.2rem;
        }
        
        /* 搜索栏 */
        .search-bar {
            padding: 10px 15px;
            background-color: var(--bg-white);
            border-bottom: 1px solid var(--border-light);
        }
        
        .search-input-group {
            position: relative;
        }
        
        .search-input {
            width: 100%;
            padding: 10px 15px 10px 40px;
            border-radius: 20px;
            border: 1px solid var(--border-light);
            font-size: 0.9rem;
            background-color: var(--bg-light);
        }
        
        .search-icon {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-light);
        }
        
        /* 相册筛选栏 */
        .album-filter {
            display: flex;
            padding: 10px 15px;
            background-color: var(--bg-white);
            border-bottom: 1px solid var(--border-light);
            overflow-x: auto;
            scrollbar-width: none;
        }
        
        .album-filter::-webkit-scrollbar {
            display: none;
        }
        
        .filter-item {
            padding: 6px 15px;
            border-radius: 15px;
            font-size: 0.9rem;
            white-space: nowrap;
            margin-right: 8px;
            color: var(--text-secondary);
        }
        
        .filter-item.active {
            background-color: var(--primary);
            color: white;
        }
        
        /* 相册视图切换 */
        .view-toggle {
            display: flex;
            justify-content: flex-end;
            padding: 10px 15px;
            background-color: var(--bg-white);
            border-bottom: 1px solid var(--border-light);
        }
        
        .toggle-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: var(--bg-light);
            border: none;
            margin-left: 10px;
            color: var(--text-secondary);
        }
        
        .toggle-btn.active {
            background-color: var(--primary);
            color: white;
        }
        
        /* 相册列表容器 */
        .album-container {
            padding: 10px;
        }
        
        /* 相册网格布局 */
        .album-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
        }
        
        /* 相册列表布局 */
        .album-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        
        /* 相册卡片基础样式 */
        .album-card {
            background-color: var(--bg-white);
            border-radius: var(--radius);
            overflow: hidden;
            box-shadow: var(--shadow);
            transition: transform 0.2s;
        }
        
        .album-card:hover {
            transform: translateY(-2px);
        }
        
        /* 网格布局相册卡片 */
        .album-card.grid {
            display: flex;
            flex-direction: column;
        }
        
        /* 列表布局相册卡片 */
        .album-card.list {
            display: flex;
            height: 120px;
        }
        
        /* 相册封面容器 */
        .album-cover {
            position: relative;
            overflow: hidden;
        }
        
        /* 网格布局封面 */
        .album-cover.grid {
            width: 100%;
            aspect-ratio: 1;
        }
        
        /* 列表布局封面 */
        .album-cover.list {
            width: 120px;
            height: 100%;
        }
        
        .album-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s;
        }
        
        .album-card:hover .album-image {
            transform: scale(1.05);
        }
        
        .image-count {
            position: absolute;
            bottom: 8px;
            right: 8px;
            background-color: rgba(0, 0, 0, 0.6);
            color: white;
            font-size: 0.8rem;
            padding: 2px 6px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            gap: 4px;
        }
        
        /* 相册信息 */
        .album-info {
            padding: 10px;
        }
        
        /* 网格布局信息 */
        .album-info.grid {
            flex: 1;
            display: flex;
            flex-direction: column;
        }
        
        /* 列表布局信息 */
        .album-info.list {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        
        .album-title {
            font-weight: 600;
            font-size: 0.95rem;
            margin-bottom: 3px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .album-meta {
            display: flex;
            align-items: center;
            font-size: 0.8rem;
            color: var(--text-secondary);
        }
        
        .album-meta.grid {
            margin-top: auto;
        }
        
        .album-date {
            display: flex;
            align-items: center;
            gap: 4px;
        }
        
        .album-likes {
            display: flex;
            align-items: center;
            gap: 4px;
            margin-left: auto;
        }
        
        /* 瀑布流布局 */
        .album-masonry {
            column-count: 2;
            column-gap: 10px;
        }
        
        .masonry-item {
            break-inside: avoid;
            margin-bottom: 10px;
        }
        
        .masonry-item .album-card {
            height: 100%;
            display: flex;
            flex-direction: column;
        }
        
        .masonry-item .album-cover {
            flex: 1;
        }
        
        /* 底部导航 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 60px;
            background-color: var(--bg-white);
            display: flex;
            justify-content: space-around;
            align-items: center;
            border-top: 1px solid var(--border-light);
            z-index: 1000;
        }
        
        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: var(--text-secondary);
            font-size: 0.7rem;
        }
        
        .nav-item i {
            font-size: 1.2rem;
            margin-bottom: 3px;
        }
        
        .nav-item.active {
            color: var(--primary);
        }
        
        /* 创建相册按钮 */
        .create-album {
            position: fixed;
            bottom: 75px;
            right: 15px;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: var(--primary);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
            z-index: 999;
        }
        
        /* 图片查看器 */
        .image-viewer {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: black;
            z-index: 3000;
            display: none;
            align-items: center;
            justify-content: center;
        }
        
        .image-viewer.show {
            display: flex;
        }
        
        .viewer-image {
            max-width: 100%;
            max-height: 100vh;
            object-fit: contain;
        }
        
        .viewer-close {
            position: absolute;
            top: 15px;
            right: 15px;
            color: white;
            font-size: 1.5rem;
            background: none;
            border: none;
        }
        
        .viewer-prev, .viewer-next {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            color: white;
            font-size: 2rem;
            background: none;
            border: none;
            padding: 20px 10px;
        }
        
        .viewer-prev {
            left: 0;
        }
        
        .viewer-next {
            right: 0;
        }
        
        .viewer-info {
            position: absolute;
            bottom: 20px;
            left: 0;
            right: 0;
            color: white;
            text-align: center;
            padding: 0 20px;
        }
        
        .viewer-title {
            font-weight: 500;
            margin-bottom: 5px;
        }
        
        .viewer-pagination {
            font-size: 0.9rem;
            opacity: 0.8;
        }
    </style>
</head>
<body>
    <!-- 顶部导航 -->
    <div class="top-nav">
        <div class="nav-left">
            <i class="fas fa-arrow-left"></i>
        </div>
        <div class="nav-title">我的相册</div>
        <div class="nav-actions">
            <i class="far fa-bell"></i>
            <i class="far fa-cog"></i>
        </div>
    </div>
    
    <!-- 搜索栏 -->
    <div class="search-bar">
        <div class="search-input-group">
            <i class="fas fa-search search-icon"></i>
            <input type="text" class="search-input" placeholder="搜索相册...">
        </div>
    </div>
    
    <!-- 相册筛选栏 -->
    <div class="album-filter">
        <div class="filter-item active">全部相册</div>
        <div class="filter-item">个人相册</div>
        <div class="filter-item">活动相册</div>
        <div class="filter-item">风景照片</div>
        <div class="filter-item">人物写真</div>
        <div class="filter-item">美食记录</div>
        <div class="filter-item">工作相关</div>
        <div class="filter-item">收藏相册</div>
    </div>
    
    <!-- 视图切换 -->
    <div class="view-toggle">
        <button class="toggle-btn active" data-view="grid" title="网格视图">
            <i class="fas fa-th"></i>
        </button>
        <button class="toggle-btn" data-view="list" title="列表视图">
            <i class="fas fa-list"></i>
        </button>
        <button class="toggle-btn" data-view="masonry" title="瀑布流视图">
            <i class="fas fa-th-large"></i>
        </button>
    </div>
    
    <!-- 相册列表容器 -->
    <div class="album-container">
        <div class="album-content album-grid">
            <!-- 相册1 -->
            <div class="album-card grid">
                <div class="album-cover grid">
                    <img src="https://picsum.photos/id/26/400/400" alt="旅行相册封面" class="album-image">
                    <div class="image-count">
                        <i class="fas fa-images"></i>
                        <span>24</span>
                    </div>
                </div>
                <div class="album-info grid">
                    <div class="album-title">夏日海边旅行</div>
                    <div class="album-meta grid">
                        <div class="album-date">
                            <i class="far fa-calendar"></i>
                            <span>2023-07-15</span>
                        </div>
                        <div class="album-likes">
                            <i class="far fa-heart"></i>
                            <span>32</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 相册2 -->
            <div class="album-card grid">
                <div class="album-cover grid">
                    <img src="https://picsum.photos/id/28/400/400" alt="生日派对相册封面" class="album-image">
                    <div class="image-count">
                        <i class="fas fa-images"></i>
                        <span>18</span>
                    </div>
                </div>
                <div class="album-info grid">
                    <div class="album-title">25岁生日派对</div>
                    <div class="album-meta grid">
                        <div class="album-date">
                            <i class="far fa-calendar"></i>
                            <span>2023-06-10</span>
                        </div>
                        <div class="album-likes">
                            <i class="far fa-heart"></i>
                            <span>56</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 相册3 -->
            <div class="album-card grid">
                <div class="album-cover grid">
                    <img src="https://picsum.photos/id/42/400/600" alt="山间徒步相册封面" class="album-image">
                    <div class="image-count">
                        <i class="fas fa-images"></i>
                        <span>36</span>
                    </div>
                </div>
                <div class="album-info grid">
                    <div class="album-title">周末山间徒步</div>
                    <div class="album-meta grid">
                        <div class="album-date">
                            <i class="far fa-calendar"></i>
                            <span>2023-05-28</span>
                        </div>
                        <div class="album-likes">
                            <i class="fas fa-heart"></i>
                            <span>48</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 相册4 -->
            <div class="album-card grid">
                <div class="album-cover grid">
                    <img src="https://picsum.photos/id/49/400/300" alt="美食相册封面" class="album-image">
                    <div class="image-count">
                        <i class="fas fa-images"></i>
                        <span>29</span>
                    </div>
                </div>
                <div class="album-info grid">
                    <div class="album-title">城市美食探索</div>
                    <div class="album-meta grid">
                        <div class="album-date">
                            <i class="far fa-calendar"></i>
                            <span>2023-04-15</span>
                        </div>
                        <div class="album-likes">
                            <i class="far fa-heart"></i>
                            <span>27</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 相册5 -->
            <div class="album-card grid">
                <div class="album-cover grid">
                    <img src="https://picsum.photos/id/65/400/400" alt="宠物相册封面" class="album-image">
                    <div class="image-count">
                        <i class="fas fa-images"></i>
                        <span>42</span>
                    </div>
                </div>
                <div class="album-info grid">
                    <div class="album-title">我家毛孩子的日常</div>
                    <div class="album-meta grid">
                        <div class="album-date">
                            <i class="far fa-calendar"></i>
                            <span>2023-03-20</span>
                        </div>
                        <div class="album-likes">
                            <i class="fas fa-heart"></i>
                            <span>89</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 相册6 -->
            <div class="album-card grid">
                <div class="album-cover grid">
                    <img src="https://picsum.photos/id/76/400/500" alt="工作项目相册封面" class="album-image">
                    <div class="image-count">
                        <i class="fas fa-images"></i>
                        <span>15</span>
                    </div>
                </div>
                <div class="album-info grid">
                    <div class="album-title">新项目启动仪式</div>
                    <div class="album-meta grid">
                        <div class="album-date">
                            <i class="far fa-calendar"></i>
                            <span>2023-02-18</span>
                        </div>
                        <div class="album-likes">
                            <i class="far fa-heart"></i>
                            <span>12</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 创建相册按钮 -->
    <div class="create-album">
        <i class="fas fa-plus"></i>
    </div>
    
    <!-- 底部导航 -->
    <div class="bottom-nav">
        <div class="nav-item">
            <i class="fas fa-home"></i>
            <span>首页</span>
        </div>
        <div class="nav-item">
            <i class="fas fa-compass"></i>
            <span>发现</span>
        </div>
        <div class="nav-item active">
            <i class="fas fa-images"></i>
            <span>相册</span>
        </div>
        <div class="nav-item">
            <i class="far fa-comment"></i>
            <span>消息</span>
        </div>
        <div class="nav-item">
            <i class="far fa-user"></i>
            <span>我的</span>
        </div>
    </div>
    
    <!-- 图片查看器 -->
    <div class="image-viewer" id="imageViewer">
        <button class="viewer-close" id="viewerClose">
            <i class="fas fa-times"></i>
        </button>
        <button class="viewer-prev" id="viewerPrev">
            <i class="fas fa-chevron-left"></i>
        </button>
        <img src="https://picsum.photos/id/26/800/800" alt="大图预览" class="viewer-image" id="viewerImage">
        <button class="viewer-next" id="viewerNext">
            <i class="fas fa-chevron-right"></i>
        </button>
        <div class="viewer-info">
            <div class="viewer-title">夏日海边旅行</div>
            <div class="viewer-pagination">1/24</div>
        </div>
    </div>
    
    <!-- Bootstrap JS Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // 相册数据
        const albums = [
            {
                id: 1,
                title: "夏日海边旅行",
                cover: "https://picsum.photos/id/26/400/400",
                date: "2023-07-15",
                likes: 32,
                count: 24,
                images: [
                    "https://picsum.photos/id/26/800/800",
                    "https://picsum.photos/id/27/800/800",
                    "https://picsum.photos/id/28/800/800",
                    "https://picsum.photos/id/29/800/800"
                ]
            },
            {
                id: 2,
                title: "25岁生日派对",
                cover: "https://picsum.photos/id/28/400/400",
                date: "2023-06-10",
                likes: 56,
                count: 18,
                images: [
                    "https://picsum.photos/id/28/800/800",
                    "https://picsum.photos/id/30/800/800",
                    "https://picsum.photos/id/31/800/800"
                ]
            },
            {
                id: 3,
                title: "周末山间徒步",
                cover: "https://picsum.photos/id/42/400/600",
                date: "2023-05-28",
                likes: 48,
                count: 36,
                images: [
                    "https://picsum.photos/id/42/800/1200",
                    "https://picsum.photos/id/43/800/1200",
                    "https://picsum.photos/id/44/800/1200"
                ]
            },
            {
                id: 4,
                title: "城市美食探索",
                cover: "https://picsum.photos/id/49/400/300",
                date: "2023-04-15",
                likes: 27,
                count: 29,
                images: [
                    "https://picsum.photos/id/49/800/600",
                    "https://picsum.photos/id/50/800/600",
                    "https://picsum.photos/id/51/800/600"
                ]
            },
            {
                id: 5,
                title: "我家毛孩子的日常",
                cover: "https://picsum.photos/id/65/400/400",
                date: "2023-03-20",
                likes: 89,
                count: 42,
                images: [
                    "https://picsum.photos/id/65/800/800",
                    "https://picsum.photos/id/66/800/800",
                    "https://picsum.photos/id/67/800/800"
                ]
            },
            {
                id: 6,
                title: "新项目启动仪式",
                cover: "https://picsum.photos/id/76/400/500",
                date: "2023-02-18",
                likes: 12,
                count: 15,
                images: [
                    "https://picsum.photos/id/76/800/1000",
                    "https://picsum.photos/id/77/800/1000",
                    "https://picsum.photos/id/78/800/1000"
                ]
            }
        ];
        
        // 当前视图类型
        let currentView = 'grid';
        // 当前相册索引
        let currentAlbumIndex = 0;
        // 当前查看的图片索引
        let currentImageIndex = 0;
        
        // 视图切换功能
        const toggleButtons = document.querySelectorAll('.toggle-btn');
        const albumContent = document.querySelector('.album-content');
        
        toggleButtons.forEach(button => {
            button.addEventListener('click', () => {
                // 更新按钮状态
                toggleButtons.forEach(btn => btn.classList.remove('active'));
                button.classList.add('active');
                
                // 获取视图类型
                currentView = button.getAttribute('data-view');
                
                // 移除所有视图类
                albumContent.classList.remove('album-grid', 'album-list', 'album-masonry');
                
                // 添加当前视图类
                albumContent.classList.add(`album-${currentView}`);
                
                // 重新渲染相册
                renderAlbums();
            });
        });
        
        // 渲染相册
        function renderAlbums() {
            // 清空容器
            albumContent.innerHTML = '';
            
            // 根据当前视图类型渲染相册
            albums.forEach((album, index) => {
                const albumCard = document.createElement('div');
                
                // 设置卡片基础类
                albumCard.className = `album-card ${currentView}`;
                
                // 根据视图类型设置不同的结构
                if (currentView === 'masonry') {
                    // 瀑布流视图需要额外的容器
                    const masonryItem = document.createElement('div');
                    masonryItem.className = 'masonry-item';
                    
                    albumCard.innerHTML = `
                        <div class="album-cover ${currentView}">
                            <img src="${album.cover}" alt="${album.title}封面" class="album-image">
                            <div class="image-count">
                                <i class="fas fa-images"></i>
                                <span>${album.count}</span>
                            </div>
                        </div>
                        <div class="album-info ${currentView}">
                            <div class="album-title">${album.title}</div>
                            <div class="album-meta ${currentView}">
                                <div class="album-date">
                                    <i class="far fa-calendar"></i>
                                    <span>${album.date}</span>
                                </div>
                                <div class="album-likes ${album.likes > 0 ? 'liked' : ''}">
                                    <i class="${album.likes > 0 ? 'fas' : 'far'} fa-heart"></i>
                                    <span>${album.likes}</span>
                                </div>
                            </div>
                        </div>
                    `;
                    
                    masonryItem.appendChild(albumCard);
                    albumContent.appendChild(masonryItem);
                } else {
                    albumCard.innerHTML = `
                        <div class="album-cover ${currentView}">
                            <img src="${album.cover}" alt="${album.title}封面" class="album-image">
                            <div class="image-count">
                                <i class="fas fa-images"></i>
                                <span>${album.count}</span>
                            </div>
                        </div>
                        <div class="album-info ${currentView}">
                            <div class="album-title">${album.title}</div>
                            <div class="album-meta ${currentView}">
                                <div class="album-date">
                                    <i class="far fa-calendar"></i>
                                    <span>${album.date}</span>
                                </div>
                                <div class="album-likes ${album.likes > 0 ? 'liked' : ''}">
                                    <i class="${album.likes > 0 ? 'fas' : 'far'} fa-heart"></i>
                                    <span>${album.likes}</span>
                                </div>
                            </div>
                        </div>
                    `;
                    
                    albumContent.appendChild(albumCard);
                }
                
                // 添加点击事件，打开相册图片查看器
                albumCard.addEventListener('click', () => {
                    currentAlbumIndex = index;
                    currentImageIndex = 0;
                    openImageViewer(album.images[0], album.title, album.images.length);
                });
                
                // 点赞按钮事件
                const likeButton = albumCard.querySelector('.album-likes');
                likeButton.addEventListener('click', (e) => {
                    e.stopPropagation(); // 阻止事件冒泡到卡片
                    const icon = likeButton.querySelector('i');
                    const countEl = likeButton.querySelector('span');
                    let count = parseInt(countEl.textContent);
                    
                    if (icon.classList.contains('far')) {
                        icon.classList.remove('far');
                        icon.classList.add('fas');
                        countEl.textContent = count + 1;
                        albums[index].likes = count + 1;
                    } else {
                        icon.classList.remove('fas');
                        icon.classList.add('far');
                        countEl.textContent = count - 1;
                        albums[index].likes = count - 1;
                    }
                });
            });
        }
        
        // 筛选功能
        const filterItems = document.querySelectorAll('.filter-item');
        filterItems.forEach(item => {
            item.addEventListener('click', () => {
                filterItems.forEach(i => i.classList.remove('active'));
                item.classList.add('active');
                
                // 在实际应用中，这里会根据筛选条件重新加载相册
                // 这里简单模拟刷新效果
                renderAlbums();
            });
        });
        
        // 图片查看器功能
        const imageViewer = document.getElementById('imageViewer');
        const viewerImage = document.getElementById('viewerImage');
        const viewerClose = document.getElementById('viewerClose');
        const viewerPrev = document.getElementById('viewerPrev');
        const viewerNext = document.getElementById('viewerNext');
        const viewerTitle = document.querySelector('.viewer-title');
        const viewerPagination = document.querySelector('.viewer-pagination');
        
        // 打开图片查看器
        function openImageViewer(imageSrc, title, total) {
            viewerImage.src = imageSrc;
            viewerTitle.textContent = title;
            viewerPagination.textContent = `${currentImageIndex + 1}/${total}`;
            imageViewer.classList.add('show');
            document.body.style.overflow = 'hidden';
        }
        
        // 关闭图片查看器
        function closeImageViewer() {
            imageViewer.classList.remove('show');
            document.body.style.overflow = '';
        }
        
        // 上一张图片
        function prevImage() {
            const currentAlbum = albums[currentAlbumIndex];
            currentImageIndex = (currentImageIndex - 1 + currentAlbum.images.length) % currentAlbum.images.length;
            viewerImage.src = currentAlbum.images[currentImageIndex];
            viewerPagination.textContent = `${currentImageIndex + 1}/${currentAlbum.images.length}`;
        }
        
        // 下一张图片
        function nextImage() {
            const currentAlbum = albums[currentAlbumIndex];
            currentImageIndex = (currentImageIndex + 1) % currentAlbum.images.length;
            viewerImage.src = currentAlbum.images[currentImageIndex];
            viewerPagination.textContent = `${currentImageIndex + 1}/${currentAlbum.images.length}`;
        }
        
        // 绑定图片查看器事件
        viewerClose.addEventListener('click', closeImageViewer);
        viewerPrev.addEventListener('click', prevImage);
        viewerNext.addEventListener('click', nextImage);
        
        // 点击查看器外部关闭
        imageViewer.addEventListener('click', (e) => {
            if (e.target === imageViewer) {
                closeImageViewer();
            }
        });
        
        // 滑动切换图片
        let startX = 0;
        imageViewer.addEventListener('touchstart', (e) => {
            startX = e.touches[0].clientX;
        }, false);
        
        imageViewer.addEventListener('touchend', (e) => {
            if (!startX) return;
            
            const endX = e.changedTouches[0].clientX;
            const diffX = endX - startX;
            
            // 滑动距离超过50px才触发切换
            if (diffX > 50) {
                prevImage();
            } else if (diffX < -50) {
                nextImage();
            }
            
            startX = 0;
        }, false);
        
        // 创建相册按钮点击事件
        document.querySelector('.create-album').addEventListener('click', () => {
            alert('创建新相册功能');
        });
        
        // 初始化页面
        renderAlbums();
    </script>
</body>
</html>

